<template>
	<ul>
		<li @click="getGdoos(goods.id)" v-for="(goods,index) in goodsList" :key="index">
			{{goods.name}}
		</li>
	</ul>
</template>

<script>
	export default{
		data:function(){
			return {
				goodsList:[
					{id:1,name:'小明'},
					{id:2,name:'小花'},
					{id:3,name:'小红'}
				]
			}
		},
		methods:{
			getGdoos:function(id)
			{
				// console.log(id)	
				// 详情页跳转是编程式路由,push后面是跳转路径
				//push里面要用反引号,这个id和函数function的id对应
				//这种形式写,后面的路由需要改成动态路由
				// this.$router.push(`/goods/detail/${id}`)
				
				// 第一个id是自定义参数名 
				// this.$router.push({path:'/goods/detail',query:{id:id}});
				
				//name是路由index.js中的name参数值,辞用name,后面参数必须用params
				this.$router.push({name:'detail',params:{id:id}});
			}
		}
	}

</script>

<style>
</style>
